package cn.dragon.eatingfish;

import javax.swing.*;

public class MajorFish extends SeaObject {

    public MajorFish() {
        super(70, 53, 10, 1, 0);
    }


    public void move(int x, int y) { // 鱼的坐标传入
        // 宽高除以2是为了将鼠标至于主角的中央
        setX(x - getWidth() / 2);
        setY(y - getHeight() / 2);
    }

    // 设置当前主角鱼头是向左还是向右
    public void setState() {
        if (World.getLX() > getX()) {
            setDirection(M_LEFT);
        } else if (World.getLX() < getX()) {
            setDirection(M_RIGHT);
        }
    }

    // 根据当前状态生成主角的图片
    @Override
    public ImageIcon getImage() {
        setState();
        if (getDirection() == M_LEFT) {
            switch (getLevel()) {
                case 1:
                    return Images.majorFish_L;
                case 2:
                    return Images.majorFish2_L;
                case 3:
                    return Images.majorFish3_L;
                case 4:
                    return Images.majorFish4_L;
                case 5:
                    return Images.majorFish5_L;
                case 6:
                    return Images.majorFish6_L;
            }

        } else {
            switch (getLevel()) {
                case 1:
                    return Images.majorFish_R;
                case 2:
                    return Images.majorFish2_R;
                case 3:
                    return Images.majorFish3_R;
                case 4:
                    return Images.majorFish4_R;
                case 5:
                    return Images.majorFish5_R;
                case 6:
                    return Images.majorFish6_R;

            }
        }
        return null;
    }

    @Override
    public void setLevel(int level) {
        super.setLevel(level);
        if (level == 1) {
            setWidth(70);
            setHeight(53);
        } else if (level == 2) {
            setWidth(85);
            setHeight(63);
        } else if (level == 3) {
            setWidth(90);
            setHeight(65);
        } else if (level == 4) {
            setWidth(100);
            setHeight(84);
        } else if (level == 5) {
            setWidth(120);
            setHeight(99);
        } else if (level == 6) {
            setWidth(280);
            setHeight(117);
        }
    }

    @Override
    public int getScore() {
        return 0;
    }

    public void addLife(int num) {
        setLife(getLife() + num);
    }

    public void goDead() {
        setLife(getLife() - 1);
    }

}
